package vip.source.pattern.part11.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * 享元工厂
 */
public class FontFactory {
    private Map<String, Font> fontMap = new HashMap<>();

    public Font getFont(String name) {
        Font font = fontMap.get(name);

        if (font == null) {
            font = new ConcreteFont(name);
            fontMap.put(name, font);
        }

        return font;
    }
}
